<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
            function newXMLHttpRequest() {

                var xmlreq = false;

                if (window.XMLHttpRequest) {

                    // Create XMLHttpRequest object in non-Microsoft browsers
                    xmlreq = new XMLHttpRequest();

                } else if (window.ActiveXObject) {

                    // Create XMLHttpRequest via MS ActiveX
                    try {
                        // Try to create XMLHttpRequest in later versions
                        // of Internet Explorer

                        xmlreq = new ActiveXObject("Msxml2.XMLHTTP");

                    } catch (e1) {

                        // Failed to create required ActiveXObject

                        try {
                            // Try version supported by older versions
                            // of Internet Explorer

                            xmlreq = new ActiveXObject("Microsoft.XMLHTTP");

                        } catch (e2) {

                            // Unable to create an XMLHttpRequest with ActiveX
                        }
                    }
                }

                return xmlreq;
            }

            function change() {

                // Obtain an XMLHttpRequest instance
                var req = newXMLHttpRequest();
                req.open("POST", "Test", true);
                req.setRequestHeader("Content-Type",
                "application/x-www-form-urlencoded");

                req.send("ajax=" + document.getElementsByName("ajax")[0].value);
                req.onreadystatechange = function () {
                    if (req.readyState == 4) {
                        if (req.status == 200) {
                            update(req.responseText);
                        }
                        else {
                            alert("HTTP error: "+req.status);
                        }
                    }
                };
            }
            function update(text) {
                document.getElementById("result").innerHTML = text;
            }
        </script>
    </head>
    <body>
        <form action="" >
            <input name="ajax" type="text" onchange="change()"/>
            <span id="result"></span>
        </form>
    </body>
</html>
